package com.ceac.kronos.ejb.entitybeans;

import com.ceac.kronos.ejb.entitybeans.Time;

import java.io.Serializable;

import java.sql.Timestamp;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@NamedQueries({
  @NamedQuery(name = "Checkpoint.findAll", query = "select o from Checkpoint o")
})
@Table(name = "CHECKPOINTS")
public class Checkpoint implements Serializable {
    @Id
    @Column(name="CHECKPOINT_ID", nullable = false)
    private Integer checkpointId;
    @Column(name="CREATED_BY")
    private Integer createdBy;
    @Column(name="CREATION_DATE")
    private Timestamp creationDate;
    private String description;
    @Column(nullable = false)
    private Float distance;
    @Column(name="FINISH_LINE", nullable = false)
    private String finishLine;
    @Column(name="LAST_UPDATED_BY")
    private Integer lastUpdatedBy;
    @Column(name="LAST_UPDATE_DATE")
    private Timestamp lastUpdateDate;
    @Column(nullable = false)
    private String name;

    @OneToOne(targetEntity = Race.class)
    @JoinColumn(columnDefinition = "RACE_ID", referencedColumnName = "RACE_ID")
    private Race race;

    @OneToMany(mappedBy = "checkpoint")
    private List<Time> times;
    
    public Checkpoint() {
    }

    public Checkpoint(Integer checkpointId, Integer createdBy,
                      Timestamp creationDate, String description,
                      Float distance, String finishLine,
                      Timestamp lastUpdateDate, Integer lastUpdatedBy,
                      String name, Race race) {
        this.checkpointId = checkpointId;
        this.createdBy = createdBy;
        this.creationDate = creationDate;
        this.description = description;
        this.distance = distance;
        this.finishLine = finishLine;
        this.lastUpdateDate = lastUpdateDate;
        this.lastUpdatedBy = lastUpdatedBy;
        this.name = name;
        this.race = race;
    }

    public Integer getCheckpointId() {
        return checkpointId;
    }

    public void setCheckpointId(Integer checkpointId) {
        this.checkpointId = checkpointId;
    }

    public Integer getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(Integer createdBy) {
        this.createdBy = createdBy;
    }

    public Timestamp getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(Timestamp creationDate) {
        this.creationDate = creationDate;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Float getDistance() {
        return distance;
    }

    public void setDistance(Float distance) {
        this.distance = distance;
    }

    public String getFinishLine() {
        return finishLine;
    }

    public void setFinishLine(String finishLine) {
        this.finishLine = finishLine;
    }

    public Integer getLastUpdatedBy() {
        return lastUpdatedBy;
    }

    public void setLastUpdatedBy(Integer lastUpdatedBy) {
        this.lastUpdatedBy = lastUpdatedBy;
    }

    public Timestamp getLastUpdateDate() {
        return lastUpdateDate;
    }

    public void setLastUpdateDate(Timestamp lastUpdateDate) {
        this.lastUpdateDate = lastUpdateDate;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    public void setRace(Race race) {
        this.race = race;
    }

    public Race getRace() {
        return race;
    }

    public void setTimes(List<Time> times) {
        this.times = times;
    }

    public List<Time> getTimes() {
        return times;
    }
}
